package com.camtc.camcenter.config.jwt;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import javax.security.auth.Subject;
import java.util.List;

/**
 * 用户名密码验证token
 *
 * @author
 * @date
 */

@Getter
@Setter
public class JwtAuthenticationToken extends UsernamePasswordAuthenticationToken {

    private static final long serialVersionUID = 1L;

    /**
     * 凭证
     */
    private String token;

    /**
     * 用户名+密码 创建Token
     *
     * @param principal   用户名
     * @param credentials 密码
     */
    public JwtAuthenticationToken(Object principal, Object credentials) {
        super(principal, credentials);
    }

    /**
     * 用户名+密码+Token 刷新Token
     *
     * @param principal   用户名
     * @param credentials 密码
     * @param token       凭证
     */
    public JwtAuthenticationToken(Object principal, Object credentials, String token) {
        super(principal, credentials);
        this.token = token;
    }

    /**
     * 用户名+密码+Token+权限集合 刷新Token
     *
     * @param principal   用户名
     * @param credentials 密码
     * @param authorities 权限集合
     * @param token       凭证
     */
    public JwtAuthenticationToken(Object principal, Object credentials, List<GrantedAuthority> authorities, String token) {
        super(principal, credentials, authorities);
        this.token = token;
    }

    /**
     * @param subject
     * @return
     */
    @Override
    public boolean implies(Subject subject) {
        return false;
    }

}
